<template>

</template>
<script setup>
import { onMounted } from 'vue';
import { showNotify } from 'vant';
import { useRoute } from 'vue-router';
import http from '../../http';
onMounted(() => {
    const route = useRoute();
    const code = route.query.code
    alert(code)
    http.get("user/callback/?code=" + code).then(res => {
        console.log(res.data)
        if (res.data.code == 200) {
            localStorage.setItem("token", res.data.query.token)
            localStorage.setItem("retoken", res.data.query.retoken)
            localStorage.setItem("userid", res.data.query.userid)
            showNotify({ type: 'success', message: '登录成功' });
            window.location.href = '/'
        } else {
            showNotify({ type: 'danger', message: '登录失败' });
        }

    })
})
</script>